from locust import HttpUser,task,between,SequentialTaskSet

class MallTask(SequentialTaskSet):
    # authCode = None
    @task
    def getauthcode(self):
        response = self.client.get(url='/mall-member/sso/getAuthCode?telephone=18729594835',name='获取验证码')
        self.authCode = response.json()['data']

    @task
    def registerUser(self):
        data = {'authCode': self.authCode, 'password': '123456', 'telephone': '18729594835', 'username': 'huice002'}
        response = self.client.post(url='/mall-member/sso/register', data=data, name='注册用户')
        print(response.json())
class MallUser(HttpUser):
    # 定义用户（一个协程）属性
    wait_time = between(1,3)
    tasks = [MallTask]

    # 定义具体的任务
